/*****************************************
 *  所属版本  系统开发平台       *
 *****************************************/
package com.adds.lvds.core.trace;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.adds.lvds.core.utils.ServerInfo;


/**
 * 
 *项目名称 ：lvds-web-utils
 *@author zhangjian
 *@time 2017-3-16上午11:34:26
 */
public class TraceTools {

	private static String logCfg = "log4j.properties";
	public static String transTraceModule(String aType){
		String ModuleName = "未知模块";
		if(TraceContent.SYSTEM.equals(aType)){
			ModuleName = "系统日志";
		}
		if(TraceContent.SYS_USER.equals(aType)){
			ModuleName = "用户管理";
		}
		if(TraceContent.WEIXIN_ORG.equals(aType)){
			ModuleName = "微信API接口-部门管理";
		}
		if(TraceContent.WEIXIN_EMPLOY.equals(aType)){
			ModuleName = "微信API接口-成员管理";
		}
		if(TraceContent.addBatchUserInfo.equals(aType)){
			ModuleName = "微信全量同步接口-企业管理";
		}
		if(TraceContent.SEND_NEW_MESSAGE.equals(aType)){
			ModuleName = "微信消息发送接口-图文消息";
		}
		if(TraceContent.USERINFO.equals(aType)){
			ModuleName = "成员接口-组织机构管理";
		}
		if(TraceContent.ORGINFO.equals(aType)){
			ModuleName = "部门接口-组织机构管理";
		}
		if(TraceContent.SEND_TEXT_MESSAGE.equals(aType)){
			ModuleName = "微信消息发送接口-文本消息";
		}
		if(TraceContent.WEIXIN_API.equals(aType)){
			ModuleName = "微信API-API接口";
		}
		if(TraceContent.WEIXIN_ACCESS_TOKEN.equals(aType)){
			ModuleName = "应用-AccessToken";
		}
		if(TraceContent.WEIXIN_JSAPI_TOKEN.equals(aType)){
			ModuleName = "应用-JsApiTicket";
		}
		if(TraceContent.APPLICATION.equals(aType)){
			ModuleName = "服务号应用";
		}
		if(TraceContent.WEIXIN_PAY.equals(aType)){
			ModuleName = "微信支付";
		}
		
		return ModuleName;
	}
	
	
	/**
	 * 定义日志错误、调试所使用的配置文件的获取
	 * @return Properties log4j的配置文件属性获取
	 */
	public Properties setupConfig() {
		String strDir = null;
		InputStream is = null;
		Properties props = null;

		try {
			strDir = ServerInfo.getServerPath();
			if (strDir != null) {
				is = new FileInputStream(strDir+"/WEB-INF/classes/"+logCfg);
			} else {
				is =this.getClass().getClassLoader().getResourceAsStream(logCfg);
			}
			props = new Properties();
			props.load(is);
			props.setProperty("log4j.appender.lvds.File", strDir + props.getProperty("log4j.appender.lvds.File"));
		} catch (FileNotFoundException ffe) {
			is = getClass().getClassLoader().getResourceAsStream(logCfg);
		} catch (IOException e) {
		}
		return props;
	}	
}
